package leetcode.algorithm.dynamicPlan;

public class 递归 {

    public static void main(String[] args) {
        aaa a  = new aaa();
        System.out.println(a.sum(3));
    }

    private static void printReverse(char[] str) {
        helper(0, str);
    }


    private static void helper(int index, char [] str) {
        if (str == null || index >= str.length) {
            return;
        }
        helper(index + 1, str);
        System.out.print(str[index]);
    }
}

class aaa {

    public static void main(String[] args) {
        aaa a  = new aaa();
        System.out.println(a.sum(3));
    }

    public int sum(int n) {
        if (n <= 1) {
            return 1;
        }
        return sum(n - 1) + n;
    }
}